package com.example.testenum;

/**
 * Created by admin on 2018/6/5.
 */
public enum ExamEnum {
    A(90,100,"优秀"),
    B(70,89,"良"),
    C(60,69,"及格"),
    D(0,59,"不及格");

    //最高分
    private int max;
    //最低分
    private int min;
    //评级
    private String assess;

    public String getAssess(){
        return assess;
    }

    ExamEnum(int min,int max,String assess){
        this.max = max;
        this.min = min;
        this.assess = assess;
    }

    @Override
    public String toString() {
        return super.toString();
    }

    public static ExamEnum get(int source){
        for (ExamEnum e: ExamEnum.values()) {
            if(source <= e.max && source >= e.min){
                return e;
            }
        }
        return null;
    }

    public static void main(String[] args) {

        System.out.println(ExamEnum.get(95).getAssess());
    }


}
